var a, t = require("../../@babel/runtime/helpers/defineProperty"), n = require("../../res/www.a9a.cn.js"), e = getApp(),
    i = 2, o = !0;
Page({
    data: {
        WWW: e.WWW,
        aid: 0,
        agent_class: "agent",
        agentbox: !1,
        currentTab: 0,
        topbar2_btm: 0,
        if_div_top: !1,
        TOP3loading: !1,
        loading_flag: !1,
        loading_ico_flag: !1,
        loading_str: "玩命加载中"
    },
    agentboxFn: function () {
        var a, t;
        "agented" == this.data.agent_class ? (t = !1, a = "agent") : (a = "agented", t = !0), this.setData({
            agent_class: a,
            agentbox: t,
            agentbox_mask_class: "alpha0_100",
            agentbox_box_class: "divTopDown"
        })
    }, agentbox_close_Fn: function () {
        var a = this;
        this.setData({agentbox_box_class: "divTopUp", agent_class: "agent"}), setTimeout((function () {
            a.setData({agentbox_mask_class: "alpha100_0"})
        }), 200), setTimeout((function () {
            a.setData({agentbox: !1})
        }), 400)
    }, onLoad: function (a) {
        var t = this;
        if (n.empty(e.globalData.aid)) var i = n.set_options_aid(t, a);
        e.get_config("_ZEAI").then((function (a) {
            t.setData({
                aid: i,
                color: e._ZEAI.color,
                rgbcolor: n.c16_rgb(e._ZEAI.color),
                nikbg: e.WWW + "/res/m/img/nikbg.png"
            }), n.set_tabbar()
        })), e.get_navigationBarTopHeight(t), o = !0, e.get_openid().then((function (a) {
            t.init()
        })), e.chklogin().then((function (a) {
        }))
    }, aidFn: function (a) {
        var t = a.currentTarget.dataset.aid;
        n.set_options_aid(this, {aid: t}), this.onPullDownRefresh(), this.agentbox_close_Fn()
    }, agent_detailFn: function (a) {
        var t = a.currentTarget.dataset.aid;
        n.empty(t) ? wx.navigateTo({url: "../about/about?t=us"}) : wx.navigateTo({url: "../agent/detail?id=" + t})
    }, aidmoreFn: function () {
        this.agentbox_close_Fn(), wx.navigateTo({url: "../agent/index"})
    }, init: function () {
        var i = this, o = {
            submitok: "index",
            openid: (a = wx.getStorageSync("COOK_U")).openid,
            unionid: a.unionid,
            aid: e.globalData.aid
        };
        wx.showLoading({title: "玩命加载中", mask: !0}), e.ajax({
            url: "index4.php", data: o, success: function (e) {
                if (wx.hideLoading(), e.cook_flag != a.flag && !i.data.singlePage) return a.flag = e.cook_flag, wx.setStorageSync("COOK_U", a), void i.onLoad();
                if (1 == e.flag) {
                    var o = e.banner;
                    if (!n.empty(e.var.m_bottom)) var s = n.escape2Html(e.var.m_bottom);
                    i.setData(t({
                        topbar: e.topbar,
                        navdiy_index: e.navdiy_index,
                        TRnav: e.TRnav,
                        banner: o,
                        IZT: e.IZT,
                        TOP3: e.TOP3,
                        PARTY: e.PARTY,
                        HN: e.HN,
                        WZ: e.WZ,
                        m_bottom: s,
                        var: e.var,
                        AGENT: e.AGENT
                    }, "ARR_index[0]", e.ULIST)), o.length > 0 && n.o("#img0", (function (a) {
                        i.setData({banner_W: a[0].width, banner_H: .288 * a[0].width})
                    }));
                    var r = n.get_tabbar_index("my_msg");
                    e.btmnewnum > 0 ? wx.setTabBarBadge({
                        index: r,
                        text: e.btmnewnum
                    }) : wx.removeTabBarBadge({index: r})
                } else wx.showToast({title: e.msg, icon: "none", mask: !0})
            }
        })
    }, onShow: function () {
        console.log('123',this.var)
        var t = this;
        if (t.data.aid != e.globalData.aid) return t.setData({aid: e.globalData.aid}), void t.onPullDownRefresh();
        a = wx.getStorageSync("COOK_U"), e.empty(a) || e.ajax({
            url: "index4.php",
            data: {submitok: "onshow", openid: a.openid, unionid: a.unionid, aid: e.globalData.aid},
            success: function (n) {
                if (1 == n.flag && n.cook_flag != a.flag) return a.flag = n.cook_flag, wx.setStorageSync("COOK_U", a), void t.onPullDownRefresh()
            }
        })
    }, setloading: function (a, t) {
        "start" == a ? this.setData({
            loading_flag: !0,
            loading_ico_flag: !0,
            loading_str: t
        }) : this.setData({loading_flag: !1, loading_ico_flag: !1, loading_str: t})
    }, onPullDownRefresh: function () {
        var a = this;
        this.agentbox_close_Fn(), wx.vibrateShort({type: "heavy"}), setTimeout((function () {
            a.setData({
                loading_flag: !1,
                loading_str: "拼命加载中",
                ARR_index: [],
                ARR_index_nodata: !1,
                guestloadP_flag: !1,
                sokind: "",
                currentTab: 0
            }), i = 2, o = !0, wx.stopPullDownRefresh(), a.init()
        }), 100)
    }, onReachBottom: function (n) {
        if (1 == this.data.var.index_ifpbl) {
            var s = this.data.ARR_index, r = this;
            if (o) {
                o = !1, r.setloading("start", "玩命加载中");
                var l = {submitok: "list", p: i, openid: a.openid, aid: e.globalData.aid};
                e.ajax({
                    url: "index4.php", data: l, success: function (a) {
                        if (i > r.data.var.guestloadP && 1 != r.data.var.iflogin) return r.setloading("stop", "请登录/注册"), o = !1, void r.setData({guestloadP_flag: !0});
                        if (1 == a.flag) {
                            var n = s.length;
                            if (a.ULIST.length < 1) return r.setloading("end", "已全部加载完毕"), void (o = !1);
                            r.setData(t({}, "ARR_index[" + n + "]", a.ULIST)), i += 1, o = !0
                        } else wx.showToast({title: a.msg, icon: "none", mask: !0});
                        r.setloading("end", "上拉加载更多")
                    }
                })
            }
        }
    }, getPhoneNumber: function (a) {
        e.getPhoneNumber({e: a, url: "../reg/reg"})
    }, topbarFn: function (a) {
        var t = a.currentTarget.dataset.f;
        switch (this.backtopFn(), t) {
            case"trend":
                wx.navigateTo({url: "../trend/trend"});
                break;
            case"izt":
                wx.navigateTo({url: "../izt/izt"})
        }
    }, topbar_moreFn: function () {
        this.setData({if_div_top: !0, div_top_mask_class: "alpha0_100", div_top_box_class: "divTopDown"})
    }, div_top_close_Fn: function () {
        var a = this;
        this.setData({div_top_box_class: "divTopUp"}), setTimeout((function () {
            a.setData({div_top_mask_class: "alpha100_0"})
        }), 200), setTimeout((function () {
            a.setData({if_div_top: !1})
        }), 400)
    }, blankFn: function () {
    }, top3Fn: function () {
        var n = this;
        n.setData({TOP3loading: !0}), e.ajax({
            url: "index4.php",
            data: {submitok: "top3", openid: a.openid, aid: e.globalData.aid},
            success: function (a) {
                1 == a.flag ? n.setData(t({}, "TOP3", a.TOP3)) : wx.showToast({
                    title: a.msg,
                    icon: "none",
                    mask: !0
                }), n.setData({TOP3loading: !1})
            }
        })
    }, WZkindFn: function (a) {
        var t = a.currentTarget.dataset.kind;
        wx.navigateTo({url: "../article/article?kind=" + t})
    }, index_parFn: function (a) {
        var t = a.currentTarget.dataset.sokind, n = a.currentTarget.dataset.sex;
        e.globalData.index_par = {sokind: t, sex: n}, wx.switchTab({url: "../user/user"})
    }, onPageScroll: function (a) {
        a.scrollTop > 100 ? this.setData({
            backtop_flag: !0,
            topbar2: !0,
            topbar2_btm: 10
        }) : this.setData({backtop_flag: !1, topbar2: !1, topbar2_btm: 0})
    }, backtopFn: function (a) {
        wx.pageScrollTo({scrollTop: 0, duration: 300})
    }, telFn: function (a) {
        wx.makePhoneCall({phoneNumber: this.data.var.tel})
    }, onShareAppMessage: function () {
        return {
            imageUrl: this.data.var.share.imgurl,
            title: this.data.var.share.title,
            path: "/pages/index/index4?aid=" + e.globalData.aid
        }
    }, onShareTimeline: function () {
        return {
            imageUrl: this.data.var.share.imgurl,
            title: this.data.var.share.title,
            query: "aid=" + e.globalData.aid,
            path: "/pages/index/index4"
        }
    }, privacy_agree: function (a) {
        console.log("agree")
    }, privacy_disagree: function (a) {
        console.log("disagree"), wx.exitMiniProgram()
    }
});